using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AutoMapper;
using ShopForWeb.Model.Basic;
using ShopForWeb.Model.View;

namespace ShopForWeb.Services.Profiles
{
    public class ShopProfile:Profile
    {
        public ShopProfile()
    {
          CreateMap<Product, ProductView>()
          .ForMember(pv => pv.CategoryName,
           opt => opt.MapFrom(p => p.OwnCaregory.CategoryName))
          .ForMember(pv => pv.Photo,
           opt => opt.MapFrom(p => String.IsNullOrEmpty(p.Photo) ? "default.jpg" : p.Photo));
   
    CreateMap<Order,OrderView>()
    .ForMember(ov=>ov.UserName,
    opt=>opt.MapFrom(o=>o.OwnUser.UserName))
    .ForMember(ov=>ov.Phone,
    opt=>opt.MapFrom(o=>o.OwnUser.Phone));
 }
    }

}